package cn.jiawei.jsql.net.protocol.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

/**
 * @author : willian fu
 * @version : 1.0
 * @date : 2020/12/18 0018 14:44
 * 处理链初始化
 */
public class JsqlChildHandler extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        channel.pipeline()
                //3 byte + 1 byte + n byte
                .addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 4, 3))
                //包解码器
                .addLast(new JsqlPacketDecoder());
                //连接池管理
                /*.addLast(new ClientPoolhandler())
                //授权校验
                .addLast(new JsqlAuthenticationHandler())
                //sql语句处理
                .addLast(new JsqlCommandHandler())
                //错误和异常处理收集
                .addLast(new Errorhandler());*/
    }
}
